In many applications of machine learning the input data has spatial structure that can, and should, be leveraged when solving associated learning problems. In this short post we discuss single-dimensional moving averages, which are widely used in machine learning as a pre-processing step for time-series problems.
You can skip around this document to particular subsections via the hyperlinks below.
Suppose we have a time series like the one shown below (a snippet of historical stock prices for a major car manufacturer). When analyzing such time series for trends it is quite common to first smooth them. One way to do this is via a moving average - wherein we take a small window and slide it along the time series from its start to finish and average the values inside. Taking the average inside of each little window tends to cancel out noisy values, resulting in a smoothed version of the original series that is easier to study. Below we animate the process of building a moving average, and as you move the slider from left to right you will see the window in which each average is computed, straddled on both sides by vertical blue bars, move from left to right across the series with the resulting moving average shown as a pink series.